<!--  -->
<template>
  <div>
    <div class="all">
      <ul>
        <li v-for="(item, index) in musicList" :key="index">
          <div class="rank">{{ index + 1 }}</div>
          <div class="img">
            <img :src="item.album.picUrl" alt="" />
            <i @click="getMusicUrl(item.id,item.name,item.artists[0].name,item.album.picUrl)" class="el-icon-video-play"></i>
          </div>
          <div class="name">{{ item.name }}</div>
          <div class="artist">{{ item.artists[0].name }}</div>
          <div class="samll-name">{{ item.name }}</div>

          <div class="score">{{ Math.floor(item.duration / 1000) | timeFormat }}</div>
        </li>
      </ul>
    </div>
  </div>
</template>

<script>
import { getMusicUrl } from 'util/findMusic.js'

export default {
  name: '',
  props: {
    musicList: []
  },
  data() {
    return {}
  },
  methods: {
    //获取歌曲播放链接
    async getMusicUrl(id) {
      this.$store.dispatch('musicPlay/saveIsPlaying', true)
      //保存当前歌曲id
      this.$store.dispatch('musicPlay/saveSongId', id)
      this.$store.dispatch("musicPlay/saveHasPlayList", id);

    }
  }
}
</script>

<style scoped>
.all ul li {
  padding-left: 20px;
  display: flex;
  height: 80px;
  background: #f9f9f9;
  align-items: center;
}
.all ul li:nth-child(2n) {
  background: #fff;
}
.all ul li:hover {
  background: #f0f1f2;
}
.all ul li .rank {
  width: 30px;
  font-size: 20px;
  color: #ddd;
}
.all ul li .img {
  position: relative;
  width: 60px;
  height: 60px;
  margin-left: 30px;
  margin-right: 10px;
}
.all ul li .img i {
  font-size: 25px;
  position: absolute;
  top: 20px;
  left: 18px;
  color: #fff;
  background: #409eff;
  border-radius: 20px;
}
.all ul li .img img {
  width: 100%;
  height: 100%;
  border-radius: 6px;
}
.all ul li .name {
  font-size: 14px;
  flex: 1;
}
.all ul li .artist {
  flex: 1;
  font-size: 13px;
  color: rgb(128, 118, 118);
}
.all ul li .samll-name {
  flex: 1;
  font-size: 12px;
  color: rgb(122, 115, 115);
}
.all ul li .score {
  width: 150px;
  font-size: 12px;
  color: rgb(128, 120, 120);
}
</style>